package _7_io_socket_http.io;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;

// todo 重启 java 应用
public class CreateProcess {

  public static void main(String[] args) throws IOException {
    Process process = new ProcessBuilder("jps", "-l").start();
    ArrayList<String> strings = new ArrayList<>();

    // Process process = new ProcessBuilder("java", "-jar", "/root/web-0.0.1.jar").start();
    InputStream inputStream = process.getInputStream();
    OutputStream outputStream = process.getOutputStream();
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
    String line = null;
    while ((line = reader.readLine()) != null) {
      if (line.endsWith(".jar")) {
        System.out.println(line);
      }
    }
    // inputStream.close();
  }

}
